﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using Microsoft.Practices.Unity;

namespace WPF60.Infrastructure.CabSupport
{
    public abstract class PresenterBase<TView, TViewModel> : IPresenter<TView>
        where TView : IView
        where TViewModel : IViewModelBase
    {

        /// <summary>
        /// setup should be called after the object is constructed
        /// so it can do anything special it needs to do after it is initialized
        /// service calls are the idea here
        /// </summary>
        public virtual void Setup()
        {
            View.DataContext = ViewModel;
        }

        /// <summary>
        /// every presenter needs a view
        /// rather than use ctor injection for each
        /// take it on the side here
        /// 
        /// some find using a property to set this anathema
        /// I think its a good trade off against ctor excess params
        /// </summary>
        [Dependency]
        public TView View{ get; set;}

        
        public object ViewObj
        {
            get { return View; }
        }


        [Dependency]
        public TViewModel ViewModel { get; set; }
        
     }
}
